<template>
  <div class="gallary" @click="cloceGallary">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <swiper-slide v-for="(item, index) in imgs" :key="index">
          <img class="gallary-img" :src="item">
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'commonGallary',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction', // 页码以分数显示
        // 这两个是表示该元素或父级元素发生dom结构变化的时候就会自我刷新一次，解决宽度不能更新的问题
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    cloceGallary () {
      this.$emit('cloceGallary')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .gallary >>> .swiper-container
    overflow inherit
  .gallary
    display flex
    flex-direction column
    justify-content center
    z-index 10
    position fixed
    left 0
    top 0
    right 0
    bottom 0
    background-color #000
    .wrapper
      padding-bottom 100%
      width 100%
      height 0
      .gallary-img
        width 100%
      .swiper-pagination
        color: #fff
        bottom -1rem
</style>
